####
#
# Copyright 2007 B. Chandler Carruth
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
####
#
# ./lib/rcons/files/cpp_file_module.rb
#
# This file provides a factored out module to manage files subject to C
# Pre-Processing, or processed through the cpp tool. This is not to be
# confused with C++ files...
#
####

require( 'rcons/file_target' )

module RCons

  # Provides an interface to manage C pre-processing instructions.
  module CppFileModule

    # Examines a file and adds any dependencies it finds due to
    # pre-processing instructions.
    def generate_deps()
      @includes = [] unless @includes

      if @compiler and @src_name and File::exists?( @src_name )
        if @compiler.respond_to?( :included_files )
          for f in @compiler.included_files( @src_name )
            @includes << FileTarget.new( @build_env, f )
            add_pre_dep( @includes.last )
          end
        end
      end
    end
  end
end

